$(function () {
  //  alert("sdsd");
    $("#upbutton").click(function () {
        if($("#pwd").val()==""){
           //alert("dddddd")
            var layer = layui.layer
                , form = layui.form;
            layer.msg('密码不能为空sss');
            return;
        }
        if ($("#pwds").val() ==""){
            //alert("sdsdddssdsdsd")
            var layer = layui.layer
                , form = layui.form;
            layer.msg('请把密码输入完整');
            return;
        }
        if($("#pwds").val()!=$("#pwd").val()){
            var layer = layui.layer
                , form = layui.form;
            layer.msg('两次密码输入不一致');
            return;
        }
        var pwd=$("#pwd").val();
        var phone=$("#phone").val();
        //alert("pwd=="+pwd+",--phone"+phone)
       $.ajax({
           type:"post",
           url:"../user/ChangePassword.json",
           data:{"pwd":pwd,"phone":phone},
           success:function (result) {
              if(result.ok=="true"){
                  location.href="../jsp/complete.jsp";
              }
              else {
                  location.href="../jsp/lose.jsp";
              }
           }
       })
    })
    //密码长度验证
    var pwd = "";
    $("#pwd").blur(function(){
        pwd=$("#pwd").val();
        if(pwd.length<6){
            var layer = layui.layer
                , form = layui.form;
            layer.msg('密码长度不能小于6位');
            return;
        } if(pwd.length>12){
            var layer = layui.layer
                , form = layui.form;
            layer.msg('密码长度不能大于12位');
            return;
        } if(!pwd.match(/[0-9]/)){
            var layer = layui.layer
                , form = layui.form;
            layer.msg('密码不能为单一数字');
            return;
        } if(!pwd.match(/[a-zA-Z]/)){
            var layer = layui.layer
                , form = layui.form;
            layer.msg('密码不能为单一字母');
            return;
        }
    })
   /* //再次验证密码
    $("#pwds").blur(function(){
        if($("#pwds").val()!=pwd){
            var layer = layui.layer
                , form = layui.form;
            layer.msg('两次密码输入不一致');
            return;
        }
    })*/
})